package com.content.Controller.show;
import com.common.Entity.Result;
import com.content.Entity.show.Show;
import com.content.Service.show.ShowService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/show")
public class ShowController {
    @Autowired
    private ShowService showService;
    @GetMapping("/getShowList")
    public Result getShowList(@RequestParam Integer pageNum,
                              @RequestParam Integer pageSize,
                              @RequestParam(required = false) String showName){
        PageInfo<Show> pageInfo = showService.getShowList(pageNum, pageSize, showName);
        return Result.success(pageInfo);
    }

    @GetMapping("/getShows")
    public Result getShows(){
        return Result.success(showService.getShows());
    }

    @PostMapping("/addShow")
    public Result addShow(@RequestBody Show show){
        showService.addShow(show);
        return Result.success();
    }

    @PutMapping("/updateShow")
    public Result updateShow(@RequestBody Show show){
        showService.updateShow(show);
        return Result.success();
    }

    @DeleteMapping("/deleteShow/{showId}")
    public Result deleteShow(@PathVariable String showId){
        showService.deleteShow(showId);
        return Result.success();
    }

    @GetMapping("/getShowById/{showId}")
    public Result getShowById(@PathVariable("showId") String showId){
        return Result.success(showService.getShowById(showId));
    }






}
